using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;

namespace E4RPManager.Controls
{
    public partial class ProductsXtraUserControl : XtraUserControl
    {
        private Controller _controller;

        #region Properties

        public Controller Controller
        {
            set
            {
                _controller = value;
                SetGridDataSource();
            }
        }

        #endregion

        public ProductsXtraUserControl()
        {
            InitializeComponent();
        }

        #region Private Methods

        private void SetGridDataSource()
        {
            var dataSet = _controller.GetProducts();
            gridControl.DataSource = null;
            gridControl.DataSource = dataSet;
            gridControl.DataMember = dataSet.Produto.TableName;
        }
        
        #endregion
        
        public GridView GridView()
        {
            return gridView;
        }

        public string ListName
        {
            get { return "ProductsXtraUserControl"; }
        }


        
    }
}
